{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "proof-wealth",
   "metadata": {},
   "source": [
    "# 一、统计bash项目的结构信息\n",
    "具体为统计每个文件，出边的表示(出边代表该文件被别的文件所引用)\n",
    "统计整个cluster被其他的cluster所引用的情况"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aboriginal-smooth",
   "metadata": {},
   "source": [
    "## 1、载入文件的出边数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "frequent-findings",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['symbol.csv',\n",
       " 'function_calls.csv',\n",
       " 'transitive.csv',\n",
       " 'funct_glob_var.csv',\n",
       " 'include.csv']"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "outedge = \"in_edge/file\"\n",
    "os.listdir(outedge)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "unlike-model",
   "metadata": {},
   "outputs": [],
   "source": [
    "includefile = os.path.join(outedge,'include.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "cooperative-eugene",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>label</th>\n",
       "      <th>name</th>\n",
       "      <th>alias.h</th>\n",
       "      <th>bashtypes.h</th>\n",
       "      <th>command.h</th>\n",
       "      <th>config-bot.h</th>\n",
       "      <th>config-top.h</th>\n",
       "      <th>config.h</th>\n",
       "      <th>externs.h</th>\n",
       "      <th>...</th>\n",
       "      <th>lib/readline/rlwinsize.h</th>\n",
       "      <th>lib/sh/fmtulong.c</th>\n",
       "      <th>lib/termcap/ltcap.h</th>\n",
       "      <th>mailcheck.h</th>\n",
       "      <th>signames.h</th>\n",
       "      <th>builtins/getopt.h</th>\n",
       "      <th>patchlevel.h</th>\n",
       "      <th>version.h</th>\n",
       "      <th>lib/malloc/shmalloc.h</th>\n",
       "      <th>include/.h</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>['general']</td>\n",
       "      <td>alias.c</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>['general']</td>\n",
       "      <td>array.c</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>['general']</td>\n",
       "      <td>arrayfunc.c</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>['general']</td>\n",
       "      <td>assoc.c</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>['general']</td>\n",
       "      <td>bashhist.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>135</td>\n",
       "      <td>['general']</td>\n",
       "      <td>variables.c</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>136</td>\n",
       "      <td>['general']</td>\n",
       "      <td>version.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>137</td>\n",
       "      <td>['general']</td>\n",
       "      <td>xmalloc.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>138</td>\n",
       "      <td>['general']</td>\n",
       "      <td>y.tab.c</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>139</td>\n",
       "      <td>[]</td>\n",
       "      <td>ygettext.tab.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>139 rows × 103 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      id        label            name  alias.h  bashtypes.h  command.h  \\\n",
       "0      1  ['general']         alias.c        1            1          1   \n",
       "1      2  ['general']         array.c        0            1          1   \n",
       "2      3  ['general']     arrayfunc.c        0            1          1   \n",
       "3      4  ['general']         assoc.c        0            1          1   \n",
       "4      5  ['general']      bashhist.c        0            0          1   \n",
       "..   ...          ...             ...      ...          ...        ...   \n",
       "134  135  ['general']     variables.c        1            0          1   \n",
       "135  136  ['general']       version.c        0            0          0   \n",
       "136  137  ['general']       xmalloc.c        0            0          0   \n",
       "137  138  ['general']         y.tab.c        1            1          1   \n",
       "138  139           []  ygettext.tab.c        0            0          0   \n",
       "\n",
       "     config-bot.h  config-top.h  config.h  externs.h  ...  \\\n",
       "0               1             1         1          1  ...   \n",
       "1               1             1         1          1  ...   \n",
       "2               1             1         1          1  ...   \n",
       "3               1             1         1          1  ...   \n",
       "4               1             1         1          1  ...   \n",
       "..            ...           ...       ...        ...  ...   \n",
       "134             1             1         1          1  ...   \n",
       "135             1             1         1          0  ...   \n",
       "136             1             1         1          0  ...   \n",
       "137             1             1         1          1  ...   \n",
       "138             0             0         0          0  ...   \n",
       "\n",
       "     lib/readline/rlwinsize.h  lib/sh/fmtulong.c  lib/termcap/ltcap.h  \\\n",
       "0                           0                  0                    0   \n",
       "1                           0                  0                    0   \n",
       "2                           0                  0                    0   \n",
       "3                           0                  0                    0   \n",
       "4                           0                  0                    0   \n",
       "..                        ...                ...                  ...   \n",
       "134                         0                  0                    0   \n",
       "135                         0                  0                    0   \n",
       "136                         0                  0                    0   \n",
       "137                         0                  0                    0   \n",
       "138                         0                  0                    0   \n",
       "\n",
       "     mailcheck.h  signames.h  builtins/getopt.h  patchlevel.h  version.h  \\\n",
       "0              0           0                  0             0          0   \n",
       "1              0           0                  0             0          0   \n",
       "2              0           0                  0             0          0   \n",
       "3              0           0                  0             0          0   \n",
       "4              0           0                  0             0          0   \n",
       "..           ...         ...                ...           ...        ...   \n",
       "134            1           0                  1             0          0   \n",
       "135            0           0                  0             1          1   \n",
       "136            0           0                  0             0          0   \n",
       "137            1           0                  0             0          0   \n",
       "138            0           0                  0             0          0   \n",
       "\n",
       "     lib/malloc/shmalloc.h  include/.h  \n",
       "0                        0           0  \n",
       "1                        0           0  \n",
       "2                        0           0  \n",
       "3                        0           0  \n",
       "4                        0           0  \n",
       "..                     ...         ...  \n",
       "134                      0           0  \n",
       "135                      0           0  \n",
       "136                      1           0  \n",
       "137                      0           0  \n",
       "138                      0           1  \n",
       "\n",
       "[139 rows x 103 columns]"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "data = pd.read_csv(includefile)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "patent-ceiling",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>alias.h</th>\n",
       "      <th>bashtypes.h</th>\n",
       "      <th>command.h</th>\n",
       "      <th>config-bot.h</th>\n",
       "      <th>config-top.h</th>\n",
       "      <th>config.h</th>\n",
       "      <th>externs.h</th>\n",
       "      <th>general.h</th>\n",
       "      <th>hashlib.h</th>\n",
       "      <th>include/chartypes.h</th>\n",
       "      <th>...</th>\n",
       "      <th>lib/readline/rlwinsize.h</th>\n",
       "      <th>lib/sh/fmtulong.c</th>\n",
       "      <th>lib/termcap/ltcap.h</th>\n",
       "      <th>mailcheck.h</th>\n",
       "      <th>signames.h</th>\n",
       "      <th>builtins/getopt.h</th>\n",
       "      <th>patchlevel.h</th>\n",
       "      <th>version.h</th>\n",
       "      <th>lib/malloc/shmalloc.h</th>\n",
       "      <th>include/.h</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>139 rows × 100 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     alias.h  bashtypes.h  command.h  config-bot.h  config-top.h  config.h  \\\n",
       "0          1            1          1             1             1         1   \n",
       "1          0            1          1             1             1         1   \n",
       "2          0            1          1             1             1         1   \n",
       "3          0            1          1             1             1         1   \n",
       "4          0            0          1             1             1         1   \n",
       "..       ...          ...        ...           ...           ...       ...   \n",
       "134        1            0          1             1             1         1   \n",
       "135        0            0          0             1             1         1   \n",
       "136        0            0          0             1             1         1   \n",
       "137        1            1          1             1             1         1   \n",
       "138        0            0          0             0             0         0   \n",
       "\n",
       "     externs.h  general.h  hashlib.h  include/chartypes.h  ...  \\\n",
       "0            1          1          1                    1  ...   \n",
       "1            1          1          1                    1  ...   \n",
       "2            1          1          1                    1  ...   \n",
       "3            1          1          1                    1  ...   \n",
       "4            1          1          1                    1  ...   \n",
       "..         ...        ...        ...                  ...  ...   \n",
       "134          1          1          1                    0  ...   \n",
       "135          0          0          0                    0  ...   \n",
       "136          0          0          0                    0  ...   \n",
       "137          1          1          1                    1  ...   \n",
       "138          0          0          0                    0  ...   \n",
       "\n",
       "     lib/readline/rlwinsize.h  lib/sh/fmtulong.c  lib/termcap/ltcap.h  \\\n",
       "0                           0                  0                    0   \n",
       "1                           0                  0                    0   \n",
       "2                           0                  0                    0   \n",
       "3                           0                  0                    0   \n",
       "4                           0                  0                    0   \n",
       "..                        ...                ...                  ...   \n",
       "134                         0                  0                    0   \n",
       "135                         0                  0                    0   \n",
       "136                         0                  0                    0   \n",
       "137                         0                  0                    0   \n",
       "138                         0                  0                    0   \n",
       "\n",
       "     mailcheck.h  signames.h  builtins/getopt.h  patchlevel.h  version.h  \\\n",
       "0              0           0                  0             0          0   \n",
       "1              0           0                  0             0          0   \n",
       "2              0           0                  0             0          0   \n",
       "3              0           0                  0             0          0   \n",
       "4              0           0                  0             0          0   \n",
       "..           ...         ...                ...           ...        ...   \n",
       "134            1           0                  1             0          0   \n",
       "135            0           0                  0             1          1   \n",
       "136            0           0                  0             0          0   \n",
       "137            1           0                  0             0          0   \n",
       "138            0           0                  0             0          0   \n",
       "\n",
       "     lib/malloc/shmalloc.h  include/.h  \n",
       "0                        0           0  \n",
       "1                        0           0  \n",
       "2                        0           0  \n",
       "3                        0           0  \n",
       "4                        0           0  \n",
       "..                     ...         ...  \n",
       "134                      0           0  \n",
       "135                      0           0  \n",
       "136                      1           0  \n",
       "137                      0           0  \n",
       "138                      0           1  \n",
       "\n",
       "[139 rows x 100 columns]"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = data.iloc[:,3:]\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "descending-theta",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>['libreadline']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                            label\n",
       "40                ['libreadline']\n",
       "41                ['libreadline']\n",
       "42                ['libreadline']\n",
       "43  ['libhistory', 'libreadline']\n",
       "44  ['libhistory', 'libreadline']\n",
       "45  ['libhistory', 'libreadline']\n",
       "46  ['libhistory', 'libreadline']\n",
       "47                ['libreadline']\n",
       "48                ['libreadline']\n",
       "49                ['libreadline']\n",
       "50                ['libreadline']\n",
       "51                ['libreadline']\n",
       "52                ['libreadline']\n",
       "53                ['libreadline']\n",
       "54                ['libreadline']\n",
       "55                ['libreadline']\n",
       "56                ['libreadline']\n",
       "57                ['libreadline']\n",
       "58                ['libreadline']\n",
       "59                ['libreadline']"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = data.iloc[:,1:2]\n",
    "y[40:60]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "superior-promise",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['alias.c'],\n",
       "       ['array.c'],\n",
       "       ['arrayfunc.c'],\n",
       "       ['assoc.c'],\n",
       "       ['bashhist.c'],\n",
       "       ['bashline.c'],\n",
       "       ['bracecomp.c'],\n",
       "       ['braces.c'],\n",
       "       ['builtins.c'],\n",
       "       ['builtins/bashgetopt.c'],\n",
       "       ['builtins/common.c'],\n",
       "       ['builtins/evalfile.c'],\n",
       "       ['builtins/evalstring.c'],\n",
       "       ['builtins/getopt.c'],\n",
       "       ['copy_cmd.c'],\n",
       "       ['dispose_cmd.c'],\n",
       "       ['error.c'],\n",
       "       ['eval.c'],\n",
       "       ['execute_cmd.c'],\n",
       "       ['expr.c'],\n",
       "       ['findcmd.c'],\n",
       "       ['flags.c'],\n",
       "       ['general.c'],\n",
       "       ['hashcmd.c'],\n",
       "       ['hashlib.c'],\n",
       "       ['input.c'],\n",
       "       ['jobs.c'],\n",
       "       ['lib/glob/glob.c'],\n",
       "       ['lib/glob/gmisc.c'],\n",
       "       ['lib/glob/smatch.c'],\n",
       "       ['lib/glob/strmatch.c'],\n",
       "       ['lib/glob/xmbsrtowcs.c'],\n",
       "       ['lib/malloc/malloc.c'],\n",
       "       ['lib/malloc/stats.c'],\n",
       "       ['lib/malloc/table.c'],\n",
       "       ['lib/malloc/trace.c'],\n",
       "       ['lib/malloc/watch.c'],\n",
       "       ['lib/readline/bind.c'],\n",
       "       ['lib/readline/callback.c'],\n",
       "       ['lib/readline/compat.c'],\n",
       "       ['lib/readline/complete.c'],\n",
       "       ['lib/readline/display.c'],\n",
       "       ['lib/readline/funmap.c'],\n",
       "       ['lib/readline/histexpand.c'],\n",
       "       ['lib/readline/histfile.c'],\n",
       "       ['lib/readline/history.c'],\n",
       "       ['lib/readline/histsearch.c'],\n",
       "       ['lib/readline/input.c'],\n",
       "       ['lib/readline/isearch.c'],\n",
       "       ['lib/readline/keymaps.c'],\n",
       "       ['lib/readline/kill.c'],\n",
       "       ['lib/readline/macro.c'],\n",
       "       ['lib/readline/mbutil.c'],\n",
       "       ['lib/readline/misc.c'],\n",
       "       ['lib/readline/nls.c'],\n",
       "       ['lib/readline/parens.c'],\n",
       "       ['lib/readline/readline.c'],\n",
       "       ['lib/readline/rltty.c'],\n",
       "       ['lib/readline/savestring.c'],\n",
       "       ['lib/readline/search.c'],\n",
       "       ['lib/readline/shell.c'],\n",
       "       ['lib/readline/signals.c'],\n",
       "       ['lib/readline/terminal.c'],\n",
       "       ['lib/readline/text.c'],\n",
       "       ['lib/readline/undo.c'],\n",
       "       ['lib/readline/util.c'],\n",
       "       ['lib/readline/vi_mode.c'],\n",
       "       ['lib/readline/xfree.c'],\n",
       "       ['lib/readline/xmalloc.c'],\n",
       "       ['lib/sh/casemod.c'],\n",
       "       ['lib/sh/clktck.c'],\n",
       "       ['lib/sh/clock.c'],\n",
       "       ['lib/sh/eaccess.c'],\n",
       "       ['lib/sh/fmtullong.c'],\n",
       "       ['lib/sh/fmtulong.c'],\n",
       "       ['lib/sh/fmtumax.c'],\n",
       "       ['lib/sh/fnxform.c'],\n",
       "       ['lib/sh/fpurge.c'],\n",
       "       ['lib/sh/getenv.c'],\n",
       "       ['lib/sh/input_avail.c'],\n",
       "       ['lib/sh/itos.c'],\n",
       "       ['lib/sh/mailstat.c'],\n",
       "       ['lib/sh/makepath.c'],\n",
       "       ['lib/sh/mbscasecmp.c'],\n",
       "       ['lib/sh/mbschr.c'],\n",
       "       ['lib/sh/mbscmp.c'],\n",
       "       ['lib/sh/netconn.c'],\n",
       "       ['lib/sh/netopen.c'],\n",
       "       ['lib/sh/oslib.c'],\n",
       "       ['lib/sh/pathcanon.c'],\n",
       "       ['lib/sh/pathphys.c'],\n",
       "       ['lib/sh/setlinebuf.c'],\n",
       "       ['lib/sh/shmatch.c'],\n",
       "       ['lib/sh/shmbchar.c'],\n",
       "       ['lib/sh/shquote.c'],\n",
       "       ['lib/sh/shtty.c'],\n",
       "       ['lib/sh/snprintf.c'],\n",
       "       ['lib/sh/spell.c'],\n",
       "       ['lib/sh/stringlist.c'],\n",
       "       ['lib/sh/stringvec.c'],\n",
       "       ['lib/sh/strnlen.c'],\n",
       "       ['lib/sh/strtrans.c'],\n",
       "       ['lib/sh/timeval.c'],\n",
       "       ['lib/sh/tmpfile.c'],\n",
       "       ['lib/sh/uconvert.c'],\n",
       "       ['lib/sh/ufuncs.c'],\n",
       "       ['lib/sh/unicode.c'],\n",
       "       ['lib/sh/wcsdup.c'],\n",
       "       ['lib/sh/winsize.c'],\n",
       "       ['lib/sh/zcatfd.c'],\n",
       "       ['lib/sh/zgetline.c'],\n",
       "       ['lib/sh/zmapfd.c'],\n",
       "       ['lib/sh/zread.c'],\n",
       "       ['lib/sh/zwrite.c'],\n",
       "       ['lib/termcap/termcap.c'],\n",
       "       ['lib/termcap/tparam.c'],\n",
       "       ['lib/tilde/tilde.c'],\n",
       "       ['list.c'],\n",
       "       ['locale.c'],\n",
       "       ['mailcheck.c'],\n",
       "       ['make_cmd.c'],\n",
       "       ['pathexp.c'],\n",
       "       ['pcomplete.c'],\n",
       "       ['pcomplib.c'],\n",
       "       ['print_cmd.c'],\n",
       "       ['redir.c'],\n",
       "       ['shell.c'],\n",
       "       ['sig.c'],\n",
       "       ['stringlib.c'],\n",
       "       ['subst.c'],\n",
       "       ['syntax.c'],\n",
       "       ['test.c'],\n",
       "       ['trap.c'],\n",
       "       ['unwind_prot.c'],\n",
       "       ['variables.c'],\n",
       "       ['version.c'],\n",
       "       ['xmalloc.c'],\n",
       "       ['y.tab.c'],\n",
       "       ['ygettext.tab.c']], dtype=object)"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name = data.iloc[:,2:3]\n",
    "name = np.array(name)\n",
    "name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "norwegian-warner",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 1, 1, ..., 0, 0, 0],\n",
       "       [0, 1, 1, ..., 0, 0, 0],\n",
       "       [0, 1, 1, ..., 0, 0, 0],\n",
       "       ...,\n",
       "       [0, 0, 0, ..., 0, 1, 0],\n",
       "       [1, 1, 1, ..., 0, 0, 0],\n",
       "       [0, 0, 0, ..., 0, 0, 1]])"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "x = np.array(x)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "assured-modern",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['libbuiltins']\"],\n",
       " [\"['libbuiltins']\"],\n",
       " [\"['libbuiltins']\"],\n",
       " [\"['libbuiltins']\"],\n",
       " [\"['libbuiltins']\"],\n",
       " [\"['libbuiltins']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['error_handling']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['job_control']\"],\n",
       " [\"['libglob']\"],\n",
       " [\"['libglob']\"],\n",
       " [\"['libglob']\"],\n",
       " [\"['libglob']\"],\n",
       " [\"['libglob']\"],\n",
       " [\"['libmalloc']\"],\n",
       " [\"['libmalloc']\"],\n",
       " [\"['libmalloc']\"],\n",
       " [\"['libmalloc']\"],\n",
       " [\"['libmalloc']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libhistory', 'libreadline']\"],\n",
       " [\"['libhistory', 'libreadline']\"],\n",
       " [\"['libhistory', 'libreadline']\"],\n",
       " [\"['libhistory', 'libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libhistory', 'libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libreadline']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh', 'libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libsh']\"],\n",
       " [\"['libtermcap']\"],\n",
       " [\"['libtermcap']\"],\n",
       " [\"['libtilde']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['signal_handling']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " [\"['general']\"],\n",
       " ['[]']]"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "labels = np.array(y).tolist()\n",
    "labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "monthly-sessions",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "def labelstr2label(labels_with_symbol:str)->list:\n",
    "    ret = []\n",
    "    labelslist = labels_with_symbol[1:-1].split(\",\")\n",
    "    for label in labelslist:\n",
    "        if label == \"\":\n",
    "            break\n",
    "        else:\n",
    "            ret.append(label[1:-1])\n",
    "    return ret\n",
    "    \n",
    "    \n",
    "def labelstr2list(label_str_list:list)->list:\n",
    "    ret = []\n",
    "    for label in label_str_list:\n",
    "        ret.append(labelstr2label(label[0]))\n",
    "    return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "broken-tourism",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "tmp = labelstr2list(labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "mineral-willow",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "139"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(tmp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "grand-height",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['libbuiltins'],\n",
       " ['libbuiltins'],\n",
       " ['libbuiltins'],\n",
       " ['libbuiltins'],\n",
       " ['libbuiltins'],\n",
       " ['libbuiltins'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['error_handling'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['job_control'],\n",
       " ['libglob'],\n",
       " ['libglob'],\n",
       " ['libglob'],\n",
       " ['libglob'],\n",
       " ['libglob'],\n",
       " ['libmalloc'],\n",
       " ['libmalloc'],\n",
       " ['libmalloc'],\n",
       " ['libmalloc'],\n",
       " ['libmalloc'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libhistory', \"'libreadline\"],\n",
       " ['libhistory', \"'libreadline\"],\n",
       " ['libhistory', \"'libreadline\"],\n",
       " ['libhistory', \"'libreadline\"],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libhistory', \"'libreadline\"],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libreadline'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh', \"'libsh\"],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libsh'],\n",
       " ['libtermcap'],\n",
       " ['libtermcap'],\n",
       " ['libtilde'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['signal_handling'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " ['general'],\n",
       " []]"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tmp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "informed-flashing",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.metrics.pairwise import cosine_similarity\n",
    "m = cosine_similarity(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "perceived-delight",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>129</th>\n",
       "      <th>130</th>\n",
       "      <th>131</th>\n",
       "      <th>132</th>\n",
       "      <th>133</th>\n",
       "      <th>134</th>\n",
       "      <th>135</th>\n",
       "      <th>136</th>\n",
       "      <th>137</th>\n",
       "      <th>138</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.557007</td>\n",
       "      <td>0.501557</td>\n",
       "      <td>0.557007</td>\n",
       "      <td>0.427960</td>\n",
       "      <td>0.470679</td>\n",
       "      <td>0.508475</td>\n",
       "      <td>0.547949</td>\n",
       "      <td>0.716115</td>\n",
       "      <td>0.554700</td>\n",
       "      <td>...</td>\n",
       "      <td>0.408930</td>\n",
       "      <td>0.320256</td>\n",
       "      <td>0.494913</td>\n",
       "      <td>0.470757</td>\n",
       "      <td>0.613941</td>\n",
       "      <td>0.435836</td>\n",
       "      <td>0.294174</td>\n",
       "      <td>0.392232</td>\n",
       "      <td>0.437014</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.557007</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.900450</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.816982</td>\n",
       "      <td>0.748777</td>\n",
       "      <td>0.882442</td>\n",
       "      <td>0.950947</td>\n",
       "      <td>0.424264</td>\n",
       "      <td>0.365148</td>\n",
       "      <td>...</td>\n",
       "      <td>0.780654</td>\n",
       "      <td>0.316228</td>\n",
       "      <td>0.888523</td>\n",
       "      <td>0.816982</td>\n",
       "      <td>0.577350</td>\n",
       "      <td>0.730297</td>\n",
       "      <td>0.258199</td>\n",
       "      <td>0.322749</td>\n",
       "      <td>0.719195</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.501557</td>\n",
       "      <td>0.900450</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.900450</td>\n",
       "      <td>0.837121</td>\n",
       "      <td>0.813733</td>\n",
       "      <td>0.821995</td>\n",
       "      <td>0.915335</td>\n",
       "      <td>0.509372</td>\n",
       "      <td>0.328798</td>\n",
       "      <td>...</td>\n",
       "      <td>0.848376</td>\n",
       "      <td>0.284747</td>\n",
       "      <td>0.906747</td>\n",
       "      <td>0.811754</td>\n",
       "      <td>0.519875</td>\n",
       "      <td>0.751538</td>\n",
       "      <td>0.348743</td>\n",
       "      <td>0.406867</td>\n",
       "      <td>0.755533</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.557007</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.900450</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.816982</td>\n",
       "      <td>0.748777</td>\n",
       "      <td>0.882442</td>\n",
       "      <td>0.950947</td>\n",
       "      <td>0.424264</td>\n",
       "      <td>0.365148</td>\n",
       "      <td>...</td>\n",
       "      <td>0.780654</td>\n",
       "      <td>0.316228</td>\n",
       "      <td>0.888523</td>\n",
       "      <td>0.816982</td>\n",
       "      <td>0.577350</td>\n",
       "      <td>0.730297</td>\n",
       "      <td>0.258199</td>\n",
       "      <td>0.322749</td>\n",
       "      <td>0.719195</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.427960</td>\n",
       "      <td>0.816982</td>\n",
       "      <td>0.837121</td>\n",
       "      <td>0.816982</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.851050</td>\n",
       "      <td>0.771517</td>\n",
       "      <td>0.775984</td>\n",
       "      <td>0.398410</td>\n",
       "      <td>0.308607</td>\n",
       "      <td>...</td>\n",
       "      <td>0.819028</td>\n",
       "      <td>0.267261</td>\n",
       "      <td>0.851064</td>\n",
       "      <td>0.785714</td>\n",
       "      <td>0.487950</td>\n",
       "      <td>0.815603</td>\n",
       "      <td>0.327327</td>\n",
       "      <td>0.381881</td>\n",
       "      <td>0.769919</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>0.435836</td>\n",
       "      <td>0.730297</td>\n",
       "      <td>0.751538</td>\n",
       "      <td>0.730297</td>\n",
       "      <td>0.815603</td>\n",
       "      <td>0.888934</td>\n",
       "      <td>0.785714</td>\n",
       "      <td>0.692763</td>\n",
       "      <td>0.368856</td>\n",
       "      <td>0.214286</td>\n",
       "      <td>...</td>\n",
       "      <td>0.716147</td>\n",
       "      <td>0.247436</td>\n",
       "      <td>0.741584</td>\n",
       "      <td>0.727430</td>\n",
       "      <td>0.406579</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.303046</td>\n",
       "      <td>0.353553</td>\n",
       "      <td>0.787839</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>0.294174</td>\n",
       "      <td>0.258199</td>\n",
       "      <td>0.348743</td>\n",
       "      <td>0.258199</td>\n",
       "      <td>0.327327</td>\n",
       "      <td>0.300000</td>\n",
       "      <td>0.235702</td>\n",
       "      <td>0.254000</td>\n",
       "      <td>0.456435</td>\n",
       "      <td>0.530330</td>\n",
       "      <td>...</td>\n",
       "      <td>0.312772</td>\n",
       "      <td>0.408248</td>\n",
       "      <td>0.344124</td>\n",
       "      <td>0.327327</td>\n",
       "      <td>0.335410</td>\n",
       "      <td>0.303046</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>0.232119</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>0.392232</td>\n",
       "      <td>0.322749</td>\n",
       "      <td>0.406867</td>\n",
       "      <td>0.322749</td>\n",
       "      <td>0.381881</td>\n",
       "      <td>0.350000</td>\n",
       "      <td>0.294628</td>\n",
       "      <td>0.317500</td>\n",
       "      <td>0.456435</td>\n",
       "      <td>0.530330</td>\n",
       "      <td>...</td>\n",
       "      <td>0.364900</td>\n",
       "      <td>0.408248</td>\n",
       "      <td>0.401478</td>\n",
       "      <td>0.381881</td>\n",
       "      <td>0.559017</td>\n",
       "      <td>0.353553</td>\n",
       "      <td>0.625000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.278543</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>0.437014</td>\n",
       "      <td>0.719195</td>\n",
       "      <td>0.755533</td>\n",
       "      <td>0.719195</td>\n",
       "      <td>0.769919</td>\n",
       "      <td>0.817059</td>\n",
       "      <td>0.787839</td>\n",
       "      <td>0.731083</td>\n",
       "      <td>0.440741</td>\n",
       "      <td>0.262613</td>\n",
       "      <td>...</td>\n",
       "      <td>0.793763</td>\n",
       "      <td>0.227429</td>\n",
       "      <td>0.724224</td>\n",
       "      <td>0.810441</td>\n",
       "      <td>0.415227</td>\n",
       "      <td>0.787839</td>\n",
       "      <td>0.232119</td>\n",
       "      <td>0.278543</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>139 rows × 139 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4         5         6    \\\n",
       "0    1.000000  0.557007  0.501557  0.557007  0.427960  0.470679  0.508475   \n",
       "1    0.557007  1.000000  0.900450  1.000000  0.816982  0.748777  0.882442   \n",
       "2    0.501557  0.900450  1.000000  0.900450  0.837121  0.813733  0.821995   \n",
       "3    0.557007  1.000000  0.900450  1.000000  0.816982  0.748777  0.882442   \n",
       "4    0.427960  0.816982  0.837121  0.816982  1.000000  0.851050  0.771517   \n",
       "..        ...       ...       ...       ...       ...       ...       ...   \n",
       "134  0.435836  0.730297  0.751538  0.730297  0.815603  0.888934  0.785714   \n",
       "135  0.294174  0.258199  0.348743  0.258199  0.327327  0.300000  0.235702   \n",
       "136  0.392232  0.322749  0.406867  0.322749  0.381881  0.350000  0.294628   \n",
       "137  0.437014  0.719195  0.755533  0.719195  0.769919  0.817059  0.787839   \n",
       "138  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000   \n",
       "\n",
       "          7         8         9    ...       129       130       131  \\\n",
       "0    0.547949  0.716115  0.554700  ...  0.408930  0.320256  0.494913   \n",
       "1    0.950947  0.424264  0.365148  ...  0.780654  0.316228  0.888523   \n",
       "2    0.915335  0.509372  0.328798  ...  0.848376  0.284747  0.906747   \n",
       "3    0.950947  0.424264  0.365148  ...  0.780654  0.316228  0.888523   \n",
       "4    0.775984  0.398410  0.308607  ...  0.819028  0.267261  0.851064   \n",
       "..        ...       ...       ...  ...       ...       ...       ...   \n",
       "134  0.692763  0.368856  0.214286  ...  0.716147  0.247436  0.741584   \n",
       "135  0.254000  0.456435  0.530330  ...  0.312772  0.408248  0.344124   \n",
       "136  0.317500  0.456435  0.530330  ...  0.364900  0.408248  0.401478   \n",
       "137  0.731083  0.440741  0.262613  ...  0.793763  0.227429  0.724224   \n",
       "138  0.000000  0.000000  0.000000  ...  0.000000  0.000000  0.000000   \n",
       "\n",
       "          132       133       134       135       136       137  138  \n",
       "0    0.470757  0.613941  0.435836  0.294174  0.392232  0.437014  0.0  \n",
       "1    0.816982  0.577350  0.730297  0.258199  0.322749  0.719195  0.0  \n",
       "2    0.811754  0.519875  0.751538  0.348743  0.406867  0.755533  0.0  \n",
       "3    0.816982  0.577350  0.730297  0.258199  0.322749  0.719195  0.0  \n",
       "4    0.785714  0.487950  0.815603  0.327327  0.381881  0.769919  0.0  \n",
       "..        ...       ...       ...       ...       ...       ...  ...  \n",
       "134  0.727430  0.406579  1.000000  0.303046  0.353553  0.787839  0.0  \n",
       "135  0.327327  0.335410  0.303046  1.000000  0.625000  0.232119  0.0  \n",
       "136  0.381881  0.559017  0.353553  0.625000  1.000000  0.278543  0.0  \n",
       "137  0.810441  0.415227  0.787839  0.232119  0.278543  1.000000  0.0  \n",
       "138  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  1.0  \n",
       "\n",
       "[139 rows x 139 columns]"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(m)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "greatest-quantity",
   "metadata": {},
   "source": [
    "# 二、查看每个文件前10个最相似的文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "ranking-willow",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np   \n",
    "import heapq\n",
    "\n",
    "def getmaxIndex(metric,n):\n",
    "    max_indexs = heapq.nlargest(n, range(len(metric)), metric.take)\n",
    "    return max_indexs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "olympic-indonesia",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 111, 8, 133, 25, 123, 24, 91, 106, 110, 1]"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getmaxIndex(m[0],11)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "banner-chain",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1.        , 0.55700665, 0.50155683, 0.55700665, 0.42796049,\n",
       "       0.47067872, 0.50847518, 0.54794903, 0.71611487, 0.5547002 ,\n",
       "       0.45291081, 0.41602515, 0.3721042 , 0.48038446, 0.5150262 ,\n",
       "       0.54794903, 0.47565149, 0.48852715, 0.44083102, 0.53931937,\n",
       "       0.41202096, 0.531085  , 0.50155683, 0.50636968, 0.56652882,\n",
       "       0.59299945, 0.42295493, 0.39223227, 0.41602515, 0.49029034,\n",
       "       0.41602515, 0.41931393, 0.41931393, 0.3721042 , 0.33968311,\n",
       "       0.3721042 , 0.33968311, 0.14322297, 0.16012815, 0.2773501 ,\n",
       "       0.14322297, 0.13867505, 0.1754116 , 0.18490007, 0.19611614,\n",
       "       0.20965697, 0.22645541, 0.14322297, 0.14322297, 0.16012815,\n",
       "       0.14824986, 0.15384615, 0.18490007, 0.14824986, 0.16012815,\n",
       "       0.1672484 , 0.14322297, 0.14824986, 0.2773501 , 0.14322297,\n",
       "       0.32025631, 0.16012815, 0.13867505, 0.14824986, 0.15384615,\n",
       "       0.14824986, 0.14322297, 0.2773501 , 0.2773501 , 0.53846154,\n",
       "       0.5547002 , 0.49613894, 0.50636968, 0.43852901, 0.39223227,\n",
       "       0.43852901, 0.49613894, 0.48038446, 0.54794903, 0.48038446,\n",
       "       0.55700665, 0.39223227, 0.54794903, 0.48038446, 0.49613894,\n",
       "       0.48038446, 0.45291081, 0.531085  , 0.531085  , 0.53931937,\n",
       "       0.53931937, 0.56613852, 0.55700665, 0.45291081, 0.52414242,\n",
       "       0.49613894, 0.48038446, 0.46225016, 0.55700665, 0.55700665,\n",
       "       0.48038446, 0.54794903, 0.41602515, 0.52321664, 0.55700665,\n",
       "       0.48038446, 0.56613852, 0.48038446, 0.5547002 , 0.5547002 ,\n",
       "       0.56613852, 0.78446454, 0.48038446, 0.39223227, 0.41602515,\n",
       "       0.41602515, 0.52414242, 0.55700665, 0.45573272, 0.48280455,\n",
       "       0.52321664, 0.46880723, 0.46604138, 0.58834841, 0.4949134 ,\n",
       "       0.45596075, 0.44877456, 0.45596075, 0.45573272, 0.40893041,\n",
       "       0.32025631, 0.4949134 , 0.47075654, 0.61394061, 0.43583587,\n",
       "       0.2941742 , 0.39223227, 0.43701422, 0.        ])"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "liberal-migration",
   "metadata": {},
   "source": [
    "## 2.1、统计一下当前文件的label与相似度前10的节点它们的label的分布"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "sacred-entity",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['alias.c'], dtype=object)"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "exact-concept",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['lib/readline/isearch.c'], dtype=object)"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name[48]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "funky-louis",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "oriented-effects",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[48]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "reduced-cholesterol",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>label</th>\n",
       "      <th>name</th>\n",
       "      <th>alias.h</th>\n",
       "      <th>bashtypes.h</th>\n",
       "      <th>command.h</th>\n",
       "      <th>config-bot.h</th>\n",
       "      <th>config-top.h</th>\n",
       "      <th>config.h</th>\n",
       "      <th>externs.h</th>\n",
       "      <th>...</th>\n",
       "      <th>lib/readline/rlwinsize.h</th>\n",
       "      <th>lib/sh/fmtulong.c</th>\n",
       "      <th>lib/termcap/ltcap.h</th>\n",
       "      <th>mailcheck.h</th>\n",
       "      <th>signames.h</th>\n",
       "      <th>builtins/getopt.h</th>\n",
       "      <th>patchlevel.h</th>\n",
       "      <th>version.h</th>\n",
       "      <th>lib/malloc/shmalloc.h</th>\n",
       "      <th>include/.h</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>45</td>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "      <td>lib/readline/histfile.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>46</td>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "      <td>lib/readline/history.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>47</td>\n",
       "      <td>['libhistory', 'libreadline']</td>\n",
       "      <td>lib/readline/histsearch.c</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 103 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    id                          label                       name  alias.h  \\\n",
       "44  45  ['libhistory', 'libreadline']    lib/readline/histfile.c        0   \n",
       "45  46  ['libhistory', 'libreadline']     lib/readline/history.c        0   \n",
       "46  47  ['libhistory', 'libreadline']  lib/readline/histsearch.c        0   \n",
       "\n",
       "    bashtypes.h  command.h  config-bot.h  config-top.h  config.h  externs.h  \\\n",
       "44            0          0             1             1         0          0   \n",
       "45            0          0             1             1         0          0   \n",
       "46            0          0             1             1         0          0   \n",
       "\n",
       "    ...  lib/readline/rlwinsize.h  lib/sh/fmtulong.c  lib/termcap/ltcap.h  \\\n",
       "44  ...                         0                  0                    0   \n",
       "45  ...                         0                  0                    0   \n",
       "46  ...                         0                  0                    0   \n",
       "\n",
       "    mailcheck.h  signames.h  builtins/getopt.h  patchlevel.h  version.h  \\\n",
       "44            0           0                  0             0          0   \n",
       "45            0           0                  0             0          0   \n",
       "46            0           0                  0             0          0   \n",
       "\n",
       "    lib/malloc/shmalloc.h  include/.h  \n",
       "44                      0           0  \n",
       "45                      0           0  \n",
       "46                      0           0  \n",
       "\n",
       "[3 rows x 103 columns]"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[[44,45,46],:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "id": "renewable-series",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "46\n",
      "0.8164965809277261\n",
      "45\n",
      "0.7559289460184544\n",
      "44\n",
      "0.7071067811865475\n",
      "43\n",
      "0.6666666666666666\n",
      "60\n",
      "0.8660254037844388\n",
      "45\n",
      "0.7559289460184544\n",
      "44\n",
      "0.7071067811865475\n",
      "43\n",
      "0.6666666666666666\n",
      "46\n",
      "0.6123724356957946\n",
      "13\n",
      "0.5773502691896258\n",
      "60\n",
      "0.8660254037844388\n",
      "45\n",
      "0.7559289460184544\n",
      "44\n",
      "0.7071067811865475\n",
      "43\n",
      "0.6666666666666666\n",
      "46\n",
      "0.6123724356957946\n",
      "13\n",
      "0.5773502691896258\n",
      "60\n",
      "0.8660254037844388\n",
      "45\n",
      "0.7559289460184544\n",
      "44\n",
      "0.7071067811865475\n",
      "43\n",
      "0.6666666666666666\n",
      "46\n",
      "0.6123724356957946\n",
      "13\n",
      "0.5773502691896258\n"
     ]
    }
   ],
   "source": [
    "same_dif=[]\n",
    "\n",
    "for i in range(len(tmp)): \n",
    "    label = tmp[i]\n",
    "    if label ==['libreadline']:\n",
    "        sames = getmaxIndex(m[i],11)\n",
    "        same=0\n",
    "        dif=0\n",
    "        for same_id in range(1,len(sames)):\n",
    "            if tmp[sames[same_id]] == label:\n",
    "                same+=1\n",
    "            else:\n",
    "                print(sames[same_id])\n",
    "                print(m[i][sames[same_id]])\n",
    "                dif+=1\n",
    "        same_dif.append([same,dif])\n",
    "        \n",
    "same_dif=pd.DataFrame(same_dif)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "id": "fantastic-technician",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['libbuiltins']"
      ]
     },
     "execution_count": 171,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tmp[sames[same_id]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "id": "formed-membrane",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     0  1\n",
       "0   10  0\n",
       "1   10  0\n",
       "2    6  4\n",
       "3   10  0\n",
       "4   10  0\n",
       "5   10  0\n",
       "6   10  0\n",
       "7   10  0\n",
       "8   10  0\n",
       "9   10  0\n",
       "10  10  0\n",
       "11  10  0\n",
       "12  10  0\n",
       "13  10  0\n",
       "14  10  0\n",
       "15  10  0\n",
       "16  10  0\n",
       "17   4  6\n",
       "18  10  0\n",
       "19  10  0\n",
       "20  10  0\n",
       "21  10  0\n",
       "22  10  0\n",
       "23  10  0\n",
       "24  10  0\n",
       "25   4  6\n",
       "26   4  6"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "same_dif"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "sitting-rugby",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "248"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "same_dif[0].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "id": "decent-disposal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "22"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "same_dif[1].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "id": "committed-arrow",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9185185185185185"
      ]
     },
     "execution_count": 175,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "same_dif[0].sum()/(same_dif[1].sum()+same_dif[0].sum())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "id": "italic-enemy",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.31654676258992803"
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "44/139"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "cooperative-robin",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>label</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>['libsh']</th>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['general']</th>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libreadline']</th>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libbuiltins']</th>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libmalloc']</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libhistory', 'libreadline']</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libglob']</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libtermcap']</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>[]</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['signal_handling']</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libtilde']</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['libsh', 'libsh']</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['job_control']</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>['error_handling']</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                0\n",
       "label                            \n",
       "['libsh']                      44\n",
       "['general']                    39\n",
       "['libreadline']                27\n",
       "['libbuiltins']                 6\n",
       "['libmalloc']                   5\n",
       "['libhistory', 'libreadline']   5\n",
       "['libglob']                     5\n",
       "['libtermcap']                  2\n",
       "[]                              1\n",
       "['signal_handling']             1\n",
       "['libtilde']                    1\n",
       "['libsh', 'libsh']              1\n",
       "['job_control']                 1\n",
       "['error_handling']              1"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(pd.DataFrame(y).value_counts())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "demanding-departure",
   "metadata": {},
   "source": [
    "## 2.2、统计每个cluster文件被各个.c文件所引用的数目以及平均的引用数目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "sealed-pulse",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "label                        \n",
       "['libsh']                        44\n",
       "['general']                      39\n",
       "['libreadline']                  27\n",
       "['libbuiltins']                   6\n",
       "['libmalloc']                     5\n",
       "['libhistory', 'libreadline']     5\n",
       "['libglob']                       5\n",
       "['libtermcap']                    2\n",
       "[]                                1\n",
       "['signal_handling']               1\n",
       "['libtilde']                      1\n",
       "['libsh', 'libsh']                1\n",
       "['job_control']                   1\n",
       "['error_handling']                1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(y).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "corporate-memory",
   "metadata": {},
   "outputs": [],
   "source": [
    "C = data.iloc[:,3:].groupby(by=data['label']).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "instant-stanley",
   "metadata": {},
   "outputs": [],
   "source": [
    "mean = C.round(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "private-liechtenstein",
   "metadata": {},
   "outputs": [],
   "source": [
    "sumtongji = data.iloc[:,3:].groupby(by=data['label']).sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "sized-badge",
   "metadata": {},
   "outputs": [],
   "source": [
    "mean.to_csv(\"mean.csv\")\n",
    "sumtongji.to_csv(\"sum.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "reported-verification",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "respective-force",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "posted-russia",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "alpha-cream",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "graphic-maria",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "subtle-night",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "final-riding",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "automatic-shift",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "willing-dependence",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "seven-marks",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "representative-venture",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "increasing-modern",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fitted-locking",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "modern-might",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "thorough-stanley",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "tracked-sierra",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "laughing-helen",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "healthy-painting",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "successful-honor",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "adolescent-estonia",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "divine-clause",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "revolutionary-discrimination",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "forward-event",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "italian-fraction",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "internal-syria",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "imposed-cowboy",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "effective-insured",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "optical-stretch",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "blocked-acoustic",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "professional-reserve",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "given-northeast",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "annual-queen",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
